#include "SceneLoader.h"
#include <io/IFileLoadMethod.h>
#include <io/IFileLoadMethods.h>
#include <xml/IXmlNode.h>
#include <log/Log.h>

namespace irr{
namespace io{

class SceneLoader:public IFileLoadMethod{
public:
	virtual void*load(irr::io::IReadFile*file,irr::core::stringc fileName){
		irr::xml::IXmlNode*node=getMethods()->getDevice()->getFactoryEnvironment()->getXmlTree(file,fileName);
		getMethods()->getDevice()->getFactoryEnvironment()->runNode(node);
		void*res=node->getTag();
		//node->drop();
		return res;
	}
	virtual bool isSupportedFile(irr::core::stringc fileName){
		return (fileName.endWith("scene") || fileName.endWith("xml"));
	}

	SceneLoader(IFileLoadMethods*methods):IFileLoadMethod(methods){}
};

void regSceneLoader(IFileLoadMethods*methods){
	methods->giveLoader(new SceneLoader(methods));
}

}
}
